package controleur;

import java.awt.CardLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import modele.Commande;
import modele.util.ModePaiement;

import vue.ModeDePaiement;
import vue.PasserCommande;

public class ModeDePaiementController {

	
	public ModeDePaiement modeDePaiement;
	public PasserCommandeController cmdctrl;
	
	public PasserCommandeController getCmdctrl() {
		return cmdctrl;
	}

	public void setCmdctrl(PasserCommandeController cmdctrl) {
		this.cmdctrl = cmdctrl;
	}

	private Commande commande;
	
	public Commande getCommande() {
		return commande;
	}

	public void setCommande(Commande commande) {
		this.commande = commande;
	}

	public ModeDePaiementController(ModeDePaiement modeDePaiement, Commande commande){
		
		this.modeDePaiement=modeDePaiement;
		this.commande=commande;
		continuer();
	}
	
	public void continuer(){
		modeDePaiement.getBtnContinuerModeDePaiment().addActionListener(new ContinuerListener());
	}
	
	class ContinuerListener implements ActionListener{

		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			if (modeDePaiement.getRdbtnParCarteBancaire().isSelected()){
				CardLayout c1= (CardLayout)modeDePaiement.getParent().getLayout();
				commande.setPaiement(ModePaiement.CARTE_BANCAIRE);	
				//modeDePaiement.getCmdctrl().getPasserCommande().getRecapt().setCommande(commande);
				modeDePaiement.getCmdctrl().setCommande(commande);
				c1.show(modeDePaiement.getParent(), "name_pcb");
				
			}
			
		}
		
	}
}
